﻿using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    #region windbg
    #region 性能探查器
    internal class Program
    {
        private static void Main(string[] args)
        {
            for (int i = 0; i < 500; i++)
            {
                var tempIndex = i;
                Task.Run(async () =>
                {
                    var task =await TestDeadLock(new Uri("http://www.baidu.com"));
                    Console.WriteLine($"--------------------------{tempIndex}------------------------");
                });
            }
        
        
            Console.Read();
        }

        public static async Task<string> TestDeadLock(Uri uri)
        {
            //Console.WriteLine("Deadlock start.....");
            using (var client = new HttpClient())
            {
                var jsonString = await client.GetStringAsync(uri);
                //Console.WriteLine("Deadlock end.....");
                return jsonString;
            }
        }
    }
    #endregion
    #endregion

    #region 性能探查器
    //internal class Program
    //{
    //    private static void Main(string[] args)
    //    {
    //        for (int i = 0; i < 10; i++)
    //        {
    //            TestSleep1();
    //            TestSleep2();
    //            TestSleep3();
    //        }
    //        Console.Read();
    //    }

    //    private static void TestSleep1()
    //    {
    //        Thread.Sleep(5000);
    //        Console.WriteLine("TestSleep1 Execute end....");
    //    }

    //    private static void TestSleep2()
    //    {
    //        Thread.Sleep(5000);
    //        Console.WriteLine("TestSleep2 Execute end....");
    //    }

    //    private static void TestSleep3()
    //    {
    //        Thread.Sleep(5000);
    //        Console.WriteLine("TestSleep3 Execute end....");
    //    }
    //}
    #endregion
}
